package vip.xiaonuo.pm.modular.enterprise.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.param.DeleteByIdParam;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.pm.modular.enterprise.entity.PmEnterpriseBankEntity;
import vip.xiaonuo.pm.modular.enterprise.param.EnterpriseBankAddParam;
import vip.xiaonuo.pm.modular.enterprise.param.EnterpriseBankEditParam;
import vip.xiaonuo.pm.modular.enterprise.param.EnterpriseBankPageParam;
import vip.xiaonuo.pm.modular.enterprise.service.PmEnterpriseBankService;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 客户银行账户信息 前端控制器
 * </p>
 *
 * @author xhs
 * @since 2025-06-04
 */
@Tag(name = "客户银行账户控制器")
@ApiSupport(author = "SNOWY_TEAM", order = 4)
@Validated
@RestController
@RequestMapping("/pm/enterpriseBank/")
public class PmEnterpriseBankController {

    @Resource
    private PmEnterpriseBankService pmEnterpriseBankService;

    /**
     * 新增客户银行账户
     *
     * @param enterpriseBankAddParam 入参
     * @return CommonResult<String>
     */
    @ApiOperationSupport(order = 1)
    @Operation(summary = "新增客户银行账户")
    @CommonLog("新增客户银行账户")
    @SaCheckPermission("/pm/enterpriseBank/add")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Validated EnterpriseBankAddParam enterpriseBankAddParam) {
        pmEnterpriseBankService.add(enterpriseBankAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑客户银行账户
     *
     * @param enterpriseBankEditParam 入参
     * @return CommonResult<String>
     */
    @ApiOperationSupport(order = 2)
    @Operation(summary = "编辑客户银行账户")
    @CommonLog("编辑客户银行账户")
    @SaCheckPermission("/pm/enterpriseBank/edit")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Validated EnterpriseBankEditParam enterpriseBankEditParam) {
        pmEnterpriseBankService.edit(enterpriseBankEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除客户银行账户
     *
     * @param DeleteIdParamList 入参
     * @return CommonResult<String>
     */
    @ApiOperationSupport(order = 3)
    @Operation(summary = "删除客户银行账户")
    @CommonLog("删除客户银行账户")
    @SaCheckPermission("/pm/enterpriseBank/delete")
    @PostMapping("/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空") List<DeleteByIdParam> DeleteIdParamList) {
        pmEnterpriseBankService.delete(DeleteIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取客户银行账户分页
     *
     * @param enterpriseBankPageParam 入参
     * @return CommonResult<Page < PmEnterpriseBankEntity>>
     */
    @ApiOperationSupport(order = 4)
    @Operation(summary = "获取客户银行账户分页")
    @SaCheckPermission("/pm/enterpriseBank/page")
    @PostMapping("/page")
    public CommonResult<Page<PmEnterpriseBankEntity>> page(@RequestBody @Validated EnterpriseBankPageParam enterpriseBankPageParam) {
        return CommonResult.data(pmEnterpriseBankService.page(enterpriseBankPageParam));
    }

}
